namespace WebApi.Middleware;

/// <summary>
/// 
/// </summary>
public class TraceIdMiddleware
{
    private readonly RequestDelegate _next;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="next"></param>
    public TraceIdMiddleware(RequestDelegate next)
    {
        _next = next;
    }
    
    /// <summary>
    /// 
    /// </summary>
    /// <param name="context"></param>
    public async Task Invoke(HttpContext context)
    {
        context.Response.Headers["X-Trace-Id"] = context.TraceIdentifier;
        
        await _next(context);
    }
}